gentoo 设置无线静态ip本来非常简单的,但是用了system就变得不一样了不以/etc/conf.d/net
作为设置静态ip了。
先说不用systemd设置静态ip的方法
在设置wifi静态ip前需要
emerge -v wpa_supplicant dhcpcd net-misc/netifrc sys-apps/ifplugd
systemctl enable dhcpcd
systemctl enable wpa_supplicant (非systemd用rc-update)
1./etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
update_config=1
network={
ssid=”###”
psk=”###”
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
group=CCMP TKIP
pairwise=CCMP TKIP
priority=5
}
2./etc/conf.d/net
modules_wlan0=”wpa_supplicant”
wpa_supplicant_wlan0=”-Dwext”
config_wlan0=”192.168.2.172 netmask 255.255.255.0”
routes_wlan0=”default via 192.168.2.1”
3 ./etc/resolv.conf
nameserver 211.136.192.6
nameserver 8.8.8.8
在systemd环境下呢就需要将第二步的改为服务cd /etc/systemd/system
nano -w static-network.service
/etc/systemd/system/static-network.service
[Unit]
Description=Static network service
After=local-fs.target
Documentation=man:ifconfig(8)
Documentation=man:route(8)
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/ifconfig wlan0 192.168.2.172 broadcast 192.168.2.255 netmask 255$
ExecStart=/bin/route add default gw 192.168.1.1 wlan0
[Install]
WantedBy=multi-user.targetchmod +x static-network.service
systemctl enable static-network.service
systemctl start static-network.service
就可以获得静态ip了